/*
 *	Debugging
 *
 *	Author:	S.C.Merrall
 *
 *	File:	debug.h
 *
 *	Contents:	init_debug - initialise debugging
 *                      DBG_CALL   - register function entry
 *                      DBG_ARGS   - list argument values
 *                      DBG_EXIT   - register function exit
 *
 *	Description:	This supplies a concise trace system which can be
 *                      witched on and off in files by including debug_off.h
 *                      instead of debug.h
 *
 *	Change History:
 *
 *	Date   Name Comment
 *    -------- ---- -------
 *    06:02:91 SCM  Created
 *    19:02:91 SCM  Added p_dbg_print - plural printer for debugging
 *    22:04:91 SCM  Added dbg_g_activem for printing plurals in debug
 *
 */

#include <mpl.h>
#include <stdio.h>
#include "proc_pair.h"
#include "mp_debug.h"
#include "constant.h"

#ifdef dbg

#undef dbg

#endif

FILE *dbg;

visible int debug_status=FALSE;
char *dbg_g_fname;
plural short dbg_g_active;
char *spaces =  "                    ";

#ifdef __STDC__

int init_debug( void )

#else

int init_debug( )

#endif

{
  char *old_dbg_fname = "init_plural?";
  char *dbg_fname = "init_debug";

  dbg_g_fname = dbg_fname;

  dbg = fopen(DBG_FNAME, "w");
 
  if (dbg == NULL) {

DBG_FAIL(fprintf(stderr,"FAIL: Unable to open debug file %s\n",DBG_FNAME));
    dbg = stderr;
    return FAIL;
  }

DBG_EXIT(fprintf(dbg,"SUCCESS"));
  return SUCCESS;

}



